package com.example.my_flea_street.util;
import com.example.my_flea_street.bean.ResponseModel;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;


public class ResponseHelper {
	public static ResponseEntity<ResponseModel> createResponse(Integer code, String msg, Object data) {
		ResponseModel res = new ResponseModel();
		res.setCode(code);
		res.setMsg(msg);
		res.setData(data);
		return new ResponseEntity<ResponseModel>(res, HttpStatus.OK);
	}

	public static ResponseEntity<ResponseModel> createResponse(Integer code, String msg) {
		ResponseModel res = new ResponseModel();
		res.setCode(code);
		res.setMsg(msg);
		res.setData(null);
		return new ResponseEntity<ResponseModel>(res, HttpStatus.OK);
	}


	/**
	 * 不需要封装参数 直接返回 ResponseModel
	 * @param res
	 * @return
	 */
	public static ResponseEntity<ResponseModel> returnResponse(ResponseModel res) {
		return new ResponseEntity<ResponseModel>(res, HttpStatus.OK);
	}
}
